package com.djzhou.gmms.service.authority.impl;

import java.util.HashMap;

import java.util.List;

import org.springframework.stereotype.Service;

import com.djzhou.gmms.model.authority.TbAuthority;
import com.djzhou.gmms.model.entity.PageBean;
import com.djzhou.gmms.model.menu.TbMenu;
import com.djzhou.gmms.model.user.VoResource;
import com.djzhou.gmms.service.authority.AuthorityService;
import com.djzhou.gmms.service.base.impl.BaseServiceImpl;


public class AuthorityServiceImpl  extends BaseServiceImpl implements AuthorityService{

	@Override
	public void add(TbAuthority t) {
		authorityDAO.insert(t);
	}

	@Override
	public void delete(Integer id) {
		TbAuthority authority=authorityDAO.queryByID(TbAuthority.class, id);
		authority.setDeleteFlag(1);
		authorityDAO.update(authority);
	}

	@Override
	public TbAuthority queryById(Integer id) {
		return authorityDAO.queryByID(TbAuthority.class, id);
	}

	@Override
	public List<TbAuthority> queryList(HashMap<String, Object> hashMap) {
		String departmentId=null;
		String companyId=null;
		String hql="from TbAuthority authority where authority.deleteFlag=0";
		StringBuffer sb=new StringBuffer();
		sb.append(hql);
		sb.append(" order by createTime");
		hql=sb.toString();
		return authorityDAO.query(hql);
	}

	@Override
	public PageBean<TbAuthority> queryPageBean(HashMap<String, Object> hashMap,
			int pageSize, int currentPage) {
		String departmentId=null;
		String companyId=null;
		String hql="from TbAuthority authority where authority.deleteFlag=0";
		StringBuffer sb=new StringBuffer();
		sb.append(hql);
		sb.append(" order by createTime desc");
		hql=sb.toString();
		PageBean<TbAuthority> pageBean=authorityDAO.selectByPage(hql, pageSize, currentPage);
		return pageBean;
	}

	@Override
	public void update(TbAuthority t) {
		authorityDAO.update(t);
	}

	@Override
	public List<TbAuthority> queryDefaultAuthorityList() {
		String hql="from TbAuthority authority where authority.deleteFlag=0 and authority.autoAuthorityFlag=999";
		return authorityDAO.query(hql);
	}
	@Override
	public VoResource query4AutoComplete(HashMap<String, Object> hashMap, String sidx,
			String sord, int pageSize, int currentPage) {
		// TODO Auto-generated method stub
		return null;
	}

}
